package MyMap;

import java.util.*;

public class demo2 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        String []str = {"A","B","C","D"};
        Random r = new Random();
        for (int i = 0; i < 80; i++) {
            int index = r.nextInt(str.length);
            list.add(str[index]);
        }
        HashMap<String,Integer> map = new HashMap<>();
        for (String name : list) {
            if(map.containsKey(name)){
                int count = map.get(name);
                count++;
                map.put(name,count);
            }else {
                map.put(name,1);
            }
        }
        Set<Map.Entry<String, Integer>> set = map.entrySet();
        int max = 0;
        for (Map.Entry<String, Integer> entry : set) {
            if(entry.getValue() > max){
                max = entry.getValue();
            }
        }
        System.out.println(map);
        System.out.println(max);
        for (Map.Entry<String,Integer> entry : set){
            if(max == entry.getValue()){
                System.out.println(entry.getKey());
            }
        }
    }
}
